package play;

import music.player;
import control.stepper;

import paint.paintCanvas;
import player.snakeObject;
import pointsHandler.point;
import tag.Canvas;
import tag.constants;
import tag.framable;
import tag.share;
import gui.frame;

public class game implements share,constants{

	static framable f = frame.getInstance();
	public static boolean gameEnds = false;
	public static Thread gameThread;
	
	public static void start(){
		
		f.setVisible(true);
		paintCanvas.generateGrid();
	
		//createPlayer(2);
		
	}
	
	public static void new_game(){
		createPlayer(1);
		point.generatePoint();
		Canvas.pane.requestFocus();
	}
	public static void createPlayer(int id){
		snakeObject snake = new snakeObject();

        // create an event source - reads from stdin
        final stepper evSrc = new stepper();
 
        // create an observer
 
        // subscribe the observer to the event source
        evSrc.addObserver( snake );
        players.put(id, snake);
        // starts the event thread
        gameThread = new Thread(evSrc);
        gameThread.start();
	}
	
	public static void quit(){
		
		f.setVisible(false);
		player.exit();
		System.exit(0);
		
	}

	public static void over() {
		gameEnds=true;
		menu.gameOver();
		
	}
	
}
